<?php

class jobsController {
	
	function __construct() {
	}

	public function render( $tplname, $data = null ) {
		$block = App::me()->viewPath. DIRECTORY_SEPARATOR . 'jobs' . DIRECTORY_SEPARATOR . $tplname;
		$tpl = App::me()->tpl;
		if( $data ) {
			if( $data->errcode ) {
				$block = App::me()->viewPath. DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . 'error';
				$tpl->assign('data', $data->errmess);
			}
			else $tpl->assign('data', $data);
		}
			
		$tpl->display($block.'.tpl');
	}
	
	public function index() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new jobs;
		$data = $model->select();
		echo json_encode( $data );
	}
	
	public function selbal() {		
		session_start();
		$model = new jobs;
		$data = $model->selbal();
		$this->render('selbal',$data);		
	}
	
	public function jobstate() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new jobs;
		$data = $model->jobstate();
		echo json_encode( $data );
	}
	
	public function find() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new jobs;
		$data = $model->find();
		echo json_encode( $data );
	}
	
	public function getpmcodes() {		
		if( !Tools::isAjax() ) return;
		session_start();		
		$model = new jobs;
		$data = $model->getpmcodes();
		echo json_encode( $data );
	}
	
	public function insert() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new jobs;
		$data = $model->insert();
		echo json_encode( $data );
	}
	
	public function update() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new jobs;
		$data = $model->update();
		echo json_encode( $data );
	}
	
	public function delete() {		
		if( !Tools::isAjax() ) return;
		session_start();
		$model = new jobs;
		$data = $model->delete();
		echo json_encode( $data );
	}
	
	public function jsload() {		
		if( !Tools::isAjax() ) return;
		App::me()->js_load('jobs.js'); break;
	}	
	
}
?>